#include "wmi_hresult.h"
#include <sstream>

using namespace std;

WMI_HResult::WMI_HResult()
{
}

WMI_HResult::WMI_HResult(const wstring& name, const wstring& description, HRESULT value)
{
    _name = name;
    _description = description;
    _hr = value;
}

WMI_HResult::WMI_HResult(const wstring& description, HRESULT value)
{
    _name = L"";
    _description = description;
    _hr = value;
}

WMI_HResult::WMI_HResult(const WMI_HResult& whr)
{
    _name = whr._name;
    _description = whr._description;
    _hr = whr._hr;
}


string WMI_HResult::toString()
{
    ostringstream oss;
    oss << _description.c_str() << ". Error code = 0x" << hex << _hr << endl;

    return oss.str();
}

wstring WMI_HResult::toWString()
{
    string str = toString();
    wstring temp(str.length(),L' ');
    copy(str.begin(), str.end(), temp.begin());
    return temp; 
}